package com.qf.controller;

import com.qf.dao.UserDao;
import com.qf.entity.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestController {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
//        SqlSessionFactory sqlSessionFactory = (SqlSessionFactory) context.getBean("sqlSessionFactory");
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        UserDao dao = sqlSession.getMapper(UserDao.class);
        //扫描器创建的dao对象的命名规则，首字母小写，其他字符与类名相同
        UserDao dao = (UserDao) context.getBean("userDao");
        User user = dao.getUserById(1004);
        System.out.println(user);
    }
}
